package com.weilele.mvvmlib.sample

import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import com.weilele.base.library.BaseFragment
import com.weilele.mvvm.utils.db_litepal.MvvmDb
import com.weilele.mvvm.utils.db_litepal.MvvmDbSupport
import com.weilele.mvvmlib.databinding.ActivityLitePalBinding

/**
 * 数据库的使用
 */
class LitePalActivity : BaseFragment<ActivityLitePalBinding>() {
    override fun initUi(savedInstanceState: Bundle?) {
        super.initUi(savedInstanceState)
        MvvmDb.setCurrentDb(MvvmDb.DbBean("music", 1, listOf(Song::class.java, Album::class.java)))
    }

    data class Song(
        var name: String,
        var singer: String
    ) : MvvmDbSupport()

    data class Album(
        var name: String,
        var singer: String
    ) : MvvmDbSupport()

    override fun isNeedToolbar(): Boolean {
        return true
    }

    override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
        menu.add("666")
        super.onCreateOptionsMenu(menu, inflater)
    }
}